<template>
  <div>
    <!-- 引入面包屑组件 -->
    <el-bread></el-bread>
    <!-- 添加按钮 -->
    <el-button @click="add" class="btnInfo" type="primary" small>添加</el-button>
    <!-- 引入表格组件 -->
    <v-list @edit="edit"></v-list>
    <v-dialog
      @cancel="cancel"
      :isShow="isShow"
      :isAdd="isAdd"
      ref="Refadd"
    ></v-dialog>
  </div>
</template>

<script>
import vList from "./list.vue";
import vDialog from "./dialog.vue";
export default {
  components: {
    vList,
    vDialog,
  },
  data() {
    return {
      isShow: false,
      isAdd: true, //它的作用是用于区分是否为添加或者编辑
    };
  },
  methods: {
    add() {
      //点击 打开弹框
      this.isShow = true;
      //告诉弹框你是一个添加
      this.isAdd = true;
    },
    //封装父组件关闭方法
    cancel(e) {
      console.log(e);
      this.isShow = e;
    },
    //封装一个打开编辑弹框事件
    edit(e) {
      console.log(e, "获取id");
      //点击 打开弹框
      this.isShow = true;
      //告诉弹框你是一个编辑
      this.isAdd = false;
      this.$refs.Refadd.lookup(e);
    },
  },
};
</script>

<style  scoped>
.btnInfo {
  margin: 20px 10px;
}
</style>
